﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace ThreadUtilHelpV2
{
    public static class ThreadToolV2
    {
        static public void UIThread(this Control control, Action code)
        {
            if (control.InvokeRequired)
            {
                Debug.WriteLine("InvokeRequired");
                control.Invoke(code);
                return;
            }
            code.Invoke();
        }
        //static public void UIThread(this Control control, MethodInvoker code)
        //{
        //    if (control.InvokeRequired)
        //    {
        //        control.Invoke(code);
        //        return;
        //    }
        //    code.Invoke();
        //}
    }
}
